{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2407631d",
   "metadata": {},
   "source": [
    "# 建立API模板"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "aebcec60",
   "metadata": {},
   "outputs": [],
   "source": [
    "# import requests\n",
    "# # 下方改为自己的key&secret\n",
    "# api_key = \"Vf1TVr0kb7C0wavMhpaKym9OSkwGRNaw\"\n",
    "# api_secret = \"\tPOyLi052sYdsVnEe-Gs27AxP9fqd7zHJ\"\n",
    "\n",
    "# detectUrl = \" ~~~ \"\n",
    "\n",
    "# payload = {\n",
    "#     \"api_key\": api_key,\n",
    "#     \"api_secret\": api_secret,\n",
    "#     \"image_url\": \" 图片链接 \"\n",
    "# }\n",
    "\n",
    "# r = requests.post(detectUrl, payload)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "d20101c2",
   "metadata": {},
   "outputs": [],
   "source": [
    "#r"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "3d172147",
   "metadata": {},
   "outputs": [],
   "source": [
    "#r.json()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1569b0f",
   "metadata": {},
   "source": [
    "# 关于Face++的API调用练习位于week2的py文章中，week2包含Face++所有的人脸检测API调用\n",
    "# 数据处理小魔法 pandas.json_normalize() 实现数据表格化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4fe058ce",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. url\n",
    "analyze_url = 'https://api-cn.faceplusplus.com/facepp/v3/face/analyze'\n",
    "\n",
    "\n",
    "# 2. api账户/通行证\n",
    "api_key = \"Vf1TVr0kb7C0wavMhpaKym9OSkwGRNaw\"\n",
    "api_secret = \"\tPOyLi052sYdsVnEe-Gs27AxP9fqd7zHJ\"\n",
    "\n",
    "# 3. 请求方法：POST\n",
    "\n",
    "# 4. 准备payload（酬载）\n",
    "payload = {\n",
    "    'api_key':API_key,\n",
    "    'api_secret':API_sercret,\n",
    "    'face_tokens':face_token,\n",
    "    'return_attributes':'gender,age,smiling,headpose,facequality,blur,eyestatus,emotion,beauty,mouthstatus,eyegaze,skinstatus'\n",
    "}\n",
    "\n",
    "# 5. 发起请求\n",
    "r = requests.post(url = analyze_url, params = payload)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
